package com.atguigu.algorithm;

public class TheReNumberInArray {
    public int duplicate(int[] numbers){
        for(int i=0;i<numbers.length;i++){
            if(numbers[i]==numbers[numbers[i]] && i!=numbers[i]){
                return numbers[i];
            }else{
                swap(numbers,i,numbers[i]);
            }
        }
        return -1;
    }
    public void swap(int[] arr,int i,int j){
        int tmp=arr[i];
        arr[i]=arr[j];
        arr[j]=tmp;
    }
}
